/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package im.filters;

import com.sun.org.apache.bcel.internal.generic.INSTANCEOF;
import java.util.StringTokenizer;
import im.eventpackage.Event;
import im.subscriptionpackage.*;
import im.trash.Drink;

/**
 *
 * @author Giovanni
 */
public class TypeEventFilter {

    public TypeEventFilter() {
    }

    public boolean filter(Event event, Object type) {
        boolean ret = false;

        if (event.getType().equals(type)) {
            ret = true;
        } else {
            ret = false;
        }

        return ret;
    }

    public boolean filterSubscription(Event event, TypeSubscription sub) {
        return ((Class)sub.getType()).isInstance(event.getType());
        
        /*boolean ret = false;

        StringTokenizer st = new StringTokenizer(sub.getHierarchy()," ");

        while (st.hasMoreTokens()) {
        String str = st.nextToken();
        if (event.getType().getClass().getSimpleName().equals(str)) {
        ret = true;
        break;
        } else {
        ret = false;
        }
        }

        return ret;*/
    }
}
